package com.qfjy.homework.liqingyu;

/**
 * @ProjectName: java2204-ch9-git-boot
 * @ClassName: FlyweightPatternTest
 * @Author: Liqingyu
 * @Date: 2022/11/10 19:18
 */
public class FlyweightPatternTest {
    private static final String[] color = {"红色", "绿色", "蓝色", "白色", "黑色"};

    public static void main(String[] args) {
        for (int i = 0; i < 20; i++) {
            Circle circle = (Circle) ShapeFactory.getCircle(getRandomColor());
            circle.setRadius(getRandomRadius());
            circle.draw();
        }
    }

    private static String getRandomColor() {
        return color[(int) (Math.random() * color.length)];
    }

    private static int getRandomRadius(){
        return (int) (Math.random()*100);
    }
}
